package com.example.web_geolocation;

import android.os.Bundle;
import android.util.Log;

import ohos.stage.ability.adapter.StageActivity;
import androidx.core.app.ActivityCompat;
import android.Manifest;
import android.content.pm.PackageManager;

/**
 * Example ace activity class, which will load ArkUI-X ability instance.
 * StageActivity is provided by ArkUI-X
 * @see <a href=
 * "https://gitee.com/arkui-x/docs/blob/master/zh-cn/application-dev/tutorial/how-to-integrate-arkui-into-android.md">
 * to build android library</a>
 */
public class EntryEntryAbilityActivity extends StageActivity {
    private String tag = "EntryEntryAbilityActivity";
    private int REQUEST_CODE = 111;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Log.e(tag, "EntryEntryAbilityActivity");
        
        setInstanceName("com.example.web_geolocation:entry:EntryAbility:");
        super.onCreate(savedInstanceState);
        checkPermission();
    }
    private void checkPermission() {
        // 请求位置权限
        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
                && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, REQUEST_CODE);
        } else {
            Log.d(tag, "checkPermission fail");
        }

    }
}
